#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>

#include "mythread.h" // 自定义子线程

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    
    // 创建子线程
    mythread* m_thread = new mythread;

    // 连接信号和槽函数
    connect(m_thread, &mythread::curNumber, this, [=](int num)
        {
            ui->lcdNumber->display(num);
        });

    // 连接信号和槽函数
    connect(ui->pushButton, &QPushButton::clicked, this, [=]()
        {
            m_thread->start();
        });
}

MainWindow::~MainWindow()
{
    delete ui;
}



